import { fetchCategoryTree } from '../../../services/good/index'

Page({
  data: {
    list: [],
  },
  async init() {
    try {
      // const result = await getCategoryList();
      const result = await fetchCategoryTree();
      this.setData({
        list: result.data,
      });
    } catch (error) {
      console.error('err:', error);
    }
  },

  onShow() {
    this.getTabBar().init();
  },
  onChange(e) {
    const { item } = e.detail;
    wx.navigateTo({
      // url: '/pages/goods/list/index',
      url: '/pages/goods/result/index?groupId=' + item.groupId + '&name=' + item.name,
    });
  },
  onLoad() {
    this.init(true);
  },
});
